home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1097 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.5 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Use of standard exception classes
  5. Date: 15 Apr 1996 12:08:31 PDT
  6. Organization: GABI Software, Sarl.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <KANZE.96Apr15210506@slsvgqt.lts.sel.alcatel.de>
  9. References: <9604121530.AA08606@sun132.spd.dsccc.com> <316F646D.552DF1DD@cantrip.org>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 15 Apr 1996 19:05:06 GMT
  12. In-Reply-To: "Nathan Myers's message of 13 Apr 1996 23:17:30 GMT
  13. Apparently-To: std-c++@ncar.UCAR.EDU
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBVAwUBMXKesUy4NqrwXLNJAQEiXwIAlBOLamSDzfmJ9NelcruqtmyAVVbq4d/s
  16.     bh7YkpGxTf1CVvQ7Np3Wq8Pv7ALTFXCB2TUKZZXvRFxITWGY5fwVQQ==
  17.     =AfyW
  18. Originator: austern@isolde.mti.sgi.com
  19.  
  20. In article <316F646D.552DF1DD@cantrip.org> "Nathan Myers
  21. <ncm@cantrip.org>" <ncm@cantrip.org> writes:
  22.  
  23. |> > Another developer on our team has asked
  24. |> >   How can we be sure that ANSI C++ library callbacks work
  25. |> >   correctly in the face of exceptions?  What if ANSI C++
  26. |> >   library code catches *our* exception?
  27. |> > 
  28. |> > Is this a problem, or are library functions required to reraise any
  29. |> > exceptions thrown by client code?
  30.  
  31. |> I assume that by "library callbacks" s/he means member functions
  32. |> invoked by library components?
  33.  
  34. |> Bad things happen if you throw during copy construction or destruction
  35. |> of a vector element.
  36.  
  37. Does this imply that `vector< string >' is unsafe.  As far as I can
  38. tell, it is impossible to write a conforming basic_string that can
  39. guarantee never to through a `bad_alloc' during copy.  (Even if
  40. basic_string normally uses a shared implementation, the semantic
  41. constraints on pointer validity after reserve would seem to exclude any
  42. sharing of the implementation in this case.  So maybe the restriction
  43. is that you are not allowed to change the size of `vector< string >' if
  44. `reserve' has been called on any of its elements.)
  45.  
  46. |> Don't let it happen.  (Yes, I know this is easier
  47. |> said than done.  Still.)   There are lots of things in the library that
  48. |> could break if a user object (or even a standard object!) throws during
  49. |> a standard function.  Probably there are some places where it would be
  50. |> safe, but the committee hasn't identified them except in iostreams, where
  51. |> it's specified under what circumstances exceptions are caught and rethrown.
  52.  
  53. If I understand what you are saying correctly, we should not use
  54. exceptions with the standard library, because it will not be required
  55. to be exception safe.  And just when everyone has been telling me that
  56. I cannot avoid exceptions, because the standard library is throwing
  57. them all over the place.  (And yes, I know.  This latter statement is
  58. just what everyone is saying; in fact, there is almost nowhere in the
  59. standard library where you cannot avoid exceptions if you want to.)
  60. -- 
  61. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  62. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  63. Conseils, itudes et rialisations en logiciel orienti objet --
  64.                 -- A la recherche d'une activiti dans une region francophone
  65. ---
  66. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  67.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  68.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  69.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  70.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  71. ]
  72.